using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerSwapResolver : IResolveEngine<FieldModel>.IResolver
{
  private Vector2Int m_pos0;
  private Vector2Int m_pos1;
  private IResolveEngine<FieldModel>.IHolder m_holder;

  public PlayerSwapResolver(Vector2Int pos0, Vector2Int pos1, IResolveEngine<FieldModel>.IHolder holder) {
    m_pos0 = pos0;
    m_pos1 = pos1;
    m_holder = holder;
  }

  public void Resolve(IResolveEngine<FieldModel>.ResolveContext context) {
    var grid = context.Model.gridModel;
    grid.SwapBall(m_pos0, m_pos1);

    var matchContext = context.Model.matchResolveContext;
    matchContext.CachePlayerSwap(m_pos0, m_pos1);
    context.pushHolder(m_holder);
  }
}
